package priv.pattern.decorator;

import org.junit.Test;
import priv.pattern.decorator.subclass.MilkCoffee;
import priv.pattern.decorator.subclass.SimpleCoffee;
import priv.pattern.decorator.subclass.PearlCoffee;

/*
 * 作者：m鹏h
 * 时间；2024/6/25 21:51
 * 描述：装饰器模式 客户端
 **/
public class CoffeeShop {
    //装饰器模式 ，在不改变现有对象结构的情况下，动态的给该对象增加一些职责（即增加其额外功能）的模式，它属于对象结构型模式
    @Test
    public void test1() {
        Coffee simpleCoffee = new SimpleCoffee();
        System.out.println("价格: " + simpleCoffee.getCost() + "; 加的佐料: " + simpleCoffee.getIngredients());

        Coffee milkCoffee = new MilkCoffee(simpleCoffee);
        System.out.println("价格: " + milkCoffee.getCost() + "; 加的佐料: " + milkCoffee.getIngredients());

        Coffee milkWhipCoffee = new PearlCoffee(milkCoffee);
        System.out.println("价格: " + milkWhipCoffee.getCost() + "; 加的佐料: " + milkWhipCoffee.getIngredients());
    }
}